﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RanchBuddy.Core.DataAccess;
using RanchBuddy.Core.DataAccess.Impl;
using RanchBuddy.Core.Domain;
using RanchBuddy.Core.Domain.Impl;
using StructureMap;

namespace RanchBuddy.Core.Services.Impl
{
    public class CompanyTypeService : ICompanyTypeService
    {
        public CompanyType GetCompanyTypeByID(int CompanyTypeID)
        {
            string cacheKey = "CompanyTypeService_GetCompanyTypeID_" + CompanyTypeID;
            CompanyType result = null;
            if(ObjectFactory.GetInstance<ICache>().Exists(cacheKey))
            {
                result = ObjectFactory.GetInstance<ICache>().Get(cacheKey) as CompanyType;
            }
            else
            {
                result = ObjectFactory.GetInstance<ICompanyTypeRepository>().GetCompanyTypeByID(CompanyTypeID);
                ObjectFactory.GetInstance<ICache>().Set(cacheKey, result);
            }
            return result;
        }
    }
}
